<template>
  <div>
    <van-address-edit
        :area-list="areaList"
        show-delete
        :address-info="addressInfo"
        save-button-text="修改"
        @save="onSave"
        @delete="onDelete"
    />
  </div>
</template>

<script>
import { areaList } from '@vant/area-data';
import { Toast } from 'vant';
export default {
  name: "addressEdit",
  created(){
    let data = JSON.parse(this.$route.query.item)
    this.addressInfo=data
    let index = data.address.indexOf("区")
    if(index<0) index = data.indexOf("县")
    this.addressInfo.addressDetail = data.address.substring(index+1)

  },
  data() {
      return {
        areaList,
        addressInfo: null
      };
    },
    methods: {
      onSave(item) {
        let instance = Toast('save OK');
        setTimeout(() => {
          instance.close()
          this.$router.push('/addressList'), 1000
        })
      },
      onDelete() {
        history.go(-1)
      }
    }
}
</script>

<style scoped>

</style>